from likeshop_api_project.api.login_api import login_model
from likeshop_api_project.base.myBase import Tools


class buy_order_model(Tools):
    path = '/api/order/buy'

    def buy_order_action(self, pay_way, goodlist, remark, action, type, address_id, use_integral, hd):
        mydata = {
                "pay_way": pay_way,
                "goods": goodlist,
                "remark": remark,
                "action": action,
                "type": type,
                "address_id": address_id,
                "use_integral": use_integral
        }
        print(self.hosturl + self.path)
        buy_order = self.huihua.post(url=self.hosturl + self.path, json=mydata, headers=hd)
        return buy_order.json()


# import requests
#
# s = requests.session()
# login = login_model(huihua=s)
# msg = login.login_action(account='17612345678', pwd='admin123', client='4')
# print(msg)
# tokena = msg['data']['token']
# hd = {
#     'token': tokena
# }
# print(hd)
# buy_order = buy_order_model(huihua=s)
#
# msg2 = buy_order.buy_order_action(pay_way=3, goodlist=[{"item_id": 6, "num": 1}], remark='', action="submit",type="buy_now", address_id=834, use_integral=1, hd=hd)
# print(msg2)
